package com.v1.video.util;

import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.v1.video.R;


public class CustomProgressDialog extends ProgressDialog {

	private Context mContext;
	private String mMessage;
	private AnimationDrawable mAnimationDrawable;

	public CustomProgressDialog(Context context, String message) {
		super(context);
		// TODO Auto-generated constructor stub
		this.mContext = context;
		this.mMessage = message;
	}

	public CustomProgressDialog(Context context, int theme, String message) {
		super(context, theme);
		this.mContext = context;
		this.mMessage = message;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		LayoutInflater inflater = LayoutInflater.from(mContext);
		View view = inflater.inflate(R.layout.layout_custom_progress, null);

		TextView mTvMessage = (TextView) view.findViewById(R.id.tv_message);
		ImageView mIvProgress = (ImageView) view
				.findViewById(R.id.iv_progress);
		mIvProgress.setImageResource(R.anim.loading_progress);
		mAnimationDrawable = (AnimationDrawable) mIvProgress.getDrawable();
		if (mAnimationDrawable != null) {
			mAnimationDrawable.setOneShot(false);
			mAnimationDrawable.start();
		}
		mTvMessage.setText(mMessage);
		setContentView(view);
	}

}
